<template>
  <div>
      <h4>汽车管理ajax</h4>
        <table border="1" width="400" cellspacing="0">
            <thead><tr><th>编号</th><th>品牌</th><th>价格</th><th>产地</th><th>操作</th></tr>
            </thead>
            <tbody><tr v-for="car in cutbean.list" :key="car.id">
                    <td>{{car.id}}</td>
                    <td>{{car.type}}</td>
                    <td>{{car.price}}</td>
                    <td>{{car.address}}</td>
                     <td><input type="button" value="删除" @click="delCar(car.id)">
                     <input type="button" value="修改" @click="findById(car.id)"></td>
                </tr></tbody>
        </table>
            <a v-for="n in cutbean.pages" :key="n" style="margin-left:10px"
            href="javascript:void(0)" @click="pageClick(n)">{{n}}</a>

        <div>
            品牌:<input type="text" v-model="param.type"><br>
            起始价格:<input type="text" v-model="param.startPrice"><br>
            结束价格:<input type="text" v-model="param.endPrice"><br>
            <input type="button" value="查询" @click="pageClick(1)">
        </div>
  </div>
</template>

<script>
export default {
   props:["cutbean","carObj"],
   data(){
        return {
            param:{page:1,type:"",startPrice:null,endPrice:null}
        }
   },
   methods:{
       pageClick(index){
            this.param.page=index;
            // this.$emit("findByItem",{page:index});
            this.$emit("findByItem",this.param);
       },
      async delCar(id){
         var info = await  this.ajax.getSubmit("/project/car/del",{id:id});
         if(info == "ok"){
                  alert("删除成功");
                   this.$emit("findByItem",{page:1});
              }
            
       },
       findById(id){
           this.$emit("findById",id);
        }
   }        
}
</script>

<style>

</style>